package com.jdd.modules.parkmonthly.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jdd.modules.parking.entity.ParkInfo;
import com.jdd.modules.parking.service.IParkInfoService;
import com.jdd.modules.parkmonthly.entity.MonthlyCarTypeConvert;
import com.jdd.modules.parkmonthly.mapper.MonthlyCarTypeConvertMapper;
import com.jdd.modules.parkmonthly.service.IMonthlyCarTypeConvertService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;


/**
 * @Description: 月卡车（多车多位）计费类型转换表
 * @Author: jdd
 * @Date: 2021-11-09
 * @Version: V1.0
 */
@Service
public class MonthlyCarTypeConvertServiceImpl extends ServiceImpl<MonthlyCarTypeConvertMapper, MonthlyCarTypeConvert> implements IMonthlyCarTypeConvertService {

    @Resource
    private IParkInfoService parkInfoService;

    @Override
    public boolean saveMonthlyCarTypeConvert(
            String plateNo,
            String parkCode,
            String areaId,
            String batchNumber,
            String carEnterId,
            Date carEnterTime,
            String monthlyTypeId,
            String monthlyTypeName) {
        MonthlyCarTypeConvert vo = new MonthlyCarTypeConvert();
        vo.setParkCode(parkCode);
        ParkInfo parkInfo = parkInfoService.findOneParkInfo(parkCode);
        vo.setParkName(parkInfo.getParkName());
        vo.setBatchNumber(batchNumber);
        vo.setCarEnterId(carEnterId);
        vo.setAreaId(areaId);
        vo.setPlateNo(plateNo);
        vo.setMonthlyTypeId(monthlyTypeId);
        vo.setMonthlyTypeName(monthlyTypeName);
        vo.setBeginTime(carEnterTime);
        vo.setEndTime(new Date());
        vo.setCreateTime(new Date());
        vo.setUpdateTime(new Date());
        return this.save(vo);
    }

}
